package cn.xopencode.appletweb.controller.record.maintransformer;

import cn.xopencode.common.framework.vo.CommonResult;
import cn.xopencode.common.framework.vo.PageResult;
import cn.xopencode.recordservice.rpc.maintransformer.dto.MainTransformerRecordCreateDTO;
import cn.xopencode.recordservice.rpc.maintransformer.dto.MainTransformerRecordPageDTO;
import cn.xopencode.recordservice.rpc.maintransformer.dto.MainTransformerRecordUpdateDTO;
import cn.xopencode.recordservice.rpc.maintransformer.vo.MainTransformerRecordEmpRelVO;
import cn.xopencode.recordservice.rpc.maintransformer.vo.MainTransformerRecordPageVO;
import cn.xopencode.recordservice.rpc.maintransformer.vo.MainTransformerRecordUpdateVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.validation.Valid;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;

@Api(tags = "主变巡检记录 API")
@RestController
@RequestMapping("/maintransformer")
@Validated
public class MainTransformerRecordController {
    /**
     * 根据查询条件 分页获取所有的主变巡检记录
     * @param pageDTO
     * @return
     */
    @PostMapping("/getAllByQuery")
    @ApiOperation("根据查询条件分页获取所有的主变巡检记录")
    public CommonResult<PageResult<MainTransformerRecordPageVO>> getPageMainTransformerRecord(MainTransformerRecordPageDTO pageDTO){
        PageResult<MainTransformerRecordPageVO> result = new PageResult<>();
        List<MainTransformerRecordPageVO> list = new ArrayList<>();

        MainTransformerRecordPageVO vo = new MainTransformerRecordPageVO();
        vo.setInspectionTime(new Date());
        vo.setEmpRels("张三、李四");
        list.add(vo);
        MainTransformerRecordPageVO vo2 = new MainTransformerRecordPageVO();
        vo2.setInspectionTime(new Date());
        vo2.setEmpRels("王一");
        list.add(vo2);
        result.setList(list);
        return CommonResult.success(result);
    }

    /**
     *  新增 主变巡检记录
     * @param roomDTO
     * @return
     */
    @PostMapping("/add")
    @ApiOperation("新增 主变巡检记录")
    public CommonResult<Integer> createRobotRoomRecord(@Valid MainTransformerRecordCreateDTO roomDTO){
        return CommonResult.success(1);
    }

    /**
     *  更新 智能机器人班机柜间巡检记录
     * @param roomDTO
     * @return
     */
    @PostMapping("/update")
    @ApiOperation("更新 主变巡检记录")
    public CommonResult<Integer> updateMainTransformerRecord(@Valid MainTransformerRecordUpdateDTO roomDTO){
        return CommonResult.success(1);
    }

    /**
     * 根据id获取配电室详细
     * @param roomId
     * @return
     */
    @GetMapping("/getById")
    @ApiOperation("根据id获取配电室详细")
    public CommonResult<MainTransformerRecordUpdateVO> getMainTransformerRecordById(String roomId){
        MainTransformerRecordUpdateVO vo = new MainTransformerRecordUpdateVO();
        vo.setInspectionTime(new Date());
        vo.setOilTemperature(55.23);
        vo.setHighPressureTemperature(55.23);
        vo.setLowPressureTemperature(55.13);
        vo.setOilLevel1(30.22);
        vo.setOilLevel2(20.22);
        vo.setSeepage(false);
        vo.setSoundNormal(false);
        vo.setLeakElectric(true);
        vo.setDayShift(true);
        vo.setId("332343242334");

        List<MainTransformerRecordEmpRelVO> list = new ArrayList<MainTransformerRecordEmpRelVO>();
        MainTransformerRecordEmpRelVO relVO = new MainTransformerRecordEmpRelVO();
        relVO.setEmpId("111");
        relVO.setId("11");
        relVO.setRecordId("332343242334");
        MainTransformerRecordEmpRelVO relVO2 = new MainTransformerRecordEmpRelVO();
        relVO2.setEmpId("222");
        relVO2.setId("22");
        relVO2.setRecordId("332343242334");
        list.add(relVO);
        list.add(relVO2);

        vo.setEmpList(list);
        return CommonResult.success(vo);
    }
}
